﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Serialization;

namespace SunwellLauncher
{
    [XmlRoot("Realmlists"), Serializable]
    public class Realmlists : INotifyPropertyChanged
    {
        //private List<Realm> realm;
        private ObservableCollection<Realm> realm;
        public event PropertyChangedEventHandler PropertyChanged;

        [XmlElement("Realm")]
        //public List<Realm> Realm
        public ObservableCollection<Realm> Realm
        {
            get { return realm; } 
            set 
            {
                realm = value;
                OnPropertyChanged("Realm");
            }
        }

        #region Constructors

        public Realmlists()
        {
        }
        //public Realmlists(List<Realm> value)
        public Realmlists(ObservableCollection<Realm> value)
        {
            this.realm = value;
        } 
        #endregion
        
        protected void OnPropertyChanged(string propName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propName));
            }
        }
    }

    public class Realm //: INotifyPropertyChanged
    {
        //public event PropertyChangedEventHandler PropertyChanged;
        //private string name;
        //private string address;
        //private string website;

        [XmlElement("name")]
        public string Name { get; set; }
        //{
        //    get { return name; }
        //    set { name = value; OnPropertyChanged("Name"); }
        //}

        [XmlElement("address")]
        public string Address { get; set; }
        //{
        //    get { return address; }
        //    set { address = value; OnPropertyChanged("Address"); }
        //}

        [XmlElement("website")]
        public string Website { get; set; }
        //{
        //    get { return website; }
        //    set { website = value; OnPropertyChanged("Website"); }
        //}

        //protected void OnPropertyChanged(string propName)
        //{
        //    PropertyChangedEventHandler handler = PropertyChanged;
        //    if (handler != null)
        //    {
        //        handler(this, new PropertyChangedEventArgs(propName));
        //    }
        //}
    }
}
